package com.jiayinlending.jiayindai.activity.mine;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jiayinlending.jiayindai.R;
import com.jiayinlending.jiayindai.activity.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.qqtheme.framework.picker.OptionPicker;

import static com.jiayinlending.jiayindai.R.id.ll_identity;

public class IdentityActivity extends BaseActivity {
    @Bind(R.id.tv_marriage)
    TextView tvMarriage;
    @Bind(R.id.iv_marriage)
    ImageView ivMarriage;
    @Bind(R.id.tv_occupation)
    TextView tvOccupation;
    @Bind(R.id.iv_occupation)
    ImageView ivOccupation;
    @Bind(R.id.tv_education)
    TextView tvEducation;
    @Bind(R.id.iv_education)
    ImageView ivEducation;
    @Bind(R.id.tv_assets)
    TextView tvAssets;
    @Bind(R.id.iv_assets)
    ImageView ivAssets;
    @Bind(ll_identity)
    LinearLayout llIdentity;
    @Bind(R.id.et_location)
    EditText etLocation;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);
        getToolbarTitle().setText("身份认证");
        getSubTitle().setText("");
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_identity;
    }


    @OnClick(R.id.iv_marriage)
    public void onViewClicked() {
        String sMarrige[] = {"已婚", "未婚"};
        selector(sMarrige, tvMarriage);
    }

    private void selector(String[] s, final TextView tv) {
        final OptionPicker picker = new OptionPicker(this, s);
        picker.setOffset(2);
        picker.setSelectedIndex(0);
        picker.setTextSize(15);
        picker.setTopBackgroundColor(getResources().getColor(R.color.topBackgroundColor));//设置顶部标题栏背景颜色
        picker.setCancelTextColor(getResources().getColor(R.color.white));
        picker.setSubmitTextColor(getResources().getColor(R.color.white));
        picker.setOnOptionPickListener(new OptionPicker.OnOptionPickListener() {
            @Override
            public void onOptionPicked(int index, String item) {
                tv.setText(item);
            }
        });
        picker.show();
    }

    @OnClick({R.id.iv_occupation, R.id.iv_education, R.id.iv_assets, ll_identity})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_occupation:
                String sOccupation[] = {"企业主", "一般上市公司员工", "一般单位（私企）员工", "其他职业"};
                selector(sOccupation, tvOccupation);
                break;
            case R.id.iv_education:
                String sEducation[] = {"硕士研究生或以上", "本科", "专科", "高中或中专", "初中或初中以下"};
                selector(sEducation, tvEducation);
                break;
            case R.id.iv_assets:
                String sAssets[] = {"无房无车", "有车无房", "有房无车", "有房有车"};
                selector(sAssets, tvAssets);
                break;
            case ll_identity:
//                llIdentity.setOnTouchListener(new View.OnTouchListener() {
//                    @Override
//                    public boolean onTouch(View v, MotionEvent event) {
//                        InputMethodManager manager = (InputMethodManager) IdentityActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
//                        if (event.getAction() == MotionEvent.ACTION_DOWN) {
//                            if (IdentityActivity.this.getCurrentFocus() != null && IdentityActivity.this.getCurrentFocus().getWindowToken() != null) {
//                                manager.hideSoftInputFromWindow(IdentityActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
//                            }
//                        }
//                        return false;
//                    }
//                });
//                IdentityActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
                break;

        }
    }
}
